<template>
    <div class="card container">
        <div class="card-body">
            <div class="row justify-content-md-center">
                <div class="col-3">
                    <div class="mb-3">
                        <label for="exampleFormControlTextarea1" class="form-label">请输入内容</label>
                        <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" v-model="content"></textarea>
                        <button type="button" class="btn btn-success" style="width: 100%; margin-top: 10px;" @click="submit_content">提交</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import $ from 'jquery'
import { ref } from 'vue';
import { useStore } from 'vuex';
import dayjs from 'dayjs';
export default {
    name: 'SubmitView',
    setup() {
        const content = ref('');
        const store = useStore();
        const currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
        const submit_content = () => {
            $.ajax({
                url: "http://47.121.28.202:8000/settings/submit/",
                type: "POST",
                data: {
                    content: content.value,
                    submit_user: store.state.user.username,
                    time: currentTime,
                },
                success() {
                    content.value = "";
                }
            })
        }
        return {
            content,
            submit_content
        }
    }
}
</script>

<style scoped>
</style>